package com.cskaoyan.javase.oop1._3memory;

/**
 * 三个对象的内存图，其中有两个引用指向同一个对象。
 * @since 11:47
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo2 {
    public static void main(String[] args) {
        Animal a = new Animal();
        Animal a2 = new Animal();
        Animal a3 = a;
        System.out.println(a == a3);
        System.out.println(a == a2);

        a.age = 100;
        System.out.println(a3.age);
        System.out.println(a);
        System.out.println(a2);
        System.out.println(a3);
    }
}

class Animal {
    int age;

    public void shout() {
        System.out.println("饿得嗷嗷叫!");
    }
}
